package com.xiaoshuidi.cloud.framework.pay.core.client.impl.yinlian.app;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.xiaoshuidi.cloud.framework.pay.core.client.PayCommonResult;
import com.xiaoshuidi.cloud.framework.pay.core.client.dto.*;
import com.xiaoshuidi.cloud.framework.pay.core.client.impl.tongshangyun.dto.EnterpriseAccountEstablishReqDTO;
import com.xiaoshuidi.cloud.framework.pay.core.client.impl.tongshangyun.dto.EnterpriseAccountEstablishRespDTO;
import com.xiaoshuidi.cloud.framework.pay.core.client.impl.yinlian.YinlianClientConfig;
import com.xiaoshuidi.cloud.framework.pay.core.client.impl.yinlian.YinlianCodeMapping;
import com.xiaoshuidi.cloud.framework.pay.core.enums.PayChannelEnum;
import lombok.extern.slf4j.Slf4j;

/**
 * 银联微信App支付
 */
@Slf4j
public class YinlianWXAppPayClient extends AbstractYinlianAppPayClient {
    public YinlianWXAppPayClient(Long channelId, YinlianClientConfig config) {
        super(channelId, PayChannelEnum.YINLIAN_WX_APP.getCode(), config, new YinlianCodeMapping());
    }

    @Override
    protected PayCommonResult<PayRefundUnifiedRespDTO> doUnifiedRefund(PayRefundUnifiedReqDTO reqDTO) throws Throwable {
        return null;
    }

    @Override
    protected PayCommonResult<?> doUnifiedClose(PayCloseUnifiedReqDTO reqDTO) throws Throwable {
        return null;
    }

    @Override
    public PayRefundNotifyDTO parseRefundNotify(PayNotifyDataDTO notifyData) {
        return null;
    }

    @SuppressWarnings("unchecked")
    @Override
    protected PayCommonResult<PayOrderUnifiedRespDTO<ObjectNode>> doUnifiedOrder(PayOrderUnifiedReqDTO reqDTO) throws Throwable {
        ObjectNode body = baseParams(config.getMerchantCode(), config.getTerminalCode());
        body.put("instMid", "APPDEFAULT");
        body.put("tradeType", "APP");
        body.put("totalAmount", reqDTO.getAmount());
        return call("/v1/netpay/wx/app-pre-order", body, (code, resp) -> new PayOrderUnifiedRespDTO<ObjectNode>()
                .setRawResponse(resp));
    }
}
